package com.jk.vehicle.core.utils;

import com.jk.vehicle.core.exception.ServiceException;

/**
 * 特殊字符处理
 *
 * @author luoxiaowen
 * @date 2018/10/22
 */
public class ReplaceUtil {
    /**
     * 特殊字符转义
     *
     * @param outBuffer
     * @return
     */
    public static String replace(String outBuffer) {
        try {
            outBuffer = outBuffer.replace("\\", "\\\\");
            outBuffer = outBuffer.replace("_", "\\_");
            outBuffer = outBuffer.replace("%", "\\%");
            outBuffer = outBuffer.replace("[", "\\[");
            outBuffer = outBuffer.replace("]", "\\]");
        } catch (Exception e) {
            throw new ServiceException("字符转义失败");
        }
        return outBuffer;
    }

}
